﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp_i18n
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void BtnExit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void CmbCulture_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selectCulture = ((ComboBoxItem)this.cmbCulture.SelectedItem).Content.ToString();

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectCulture);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectCulture);
            SetUIText();
        }

        private void SetUIText()
        {
            ResourceManager rm = new ResourceManager("WpfApp_i18n.Resources.AppStrings"
                , Assembly.GetExecutingAssembly());
            lblUsername.Content = rm.GetString("Username");
            lblPassword.Content = rm.GetString("Password");
            lblLoginDate.Content = rm.GetString("LoginDate");
            lblSelectCulture.Content = rm.GetString("SelectCulture");
            btnExit.Content = rm.GetString("Exit");
            btnLogin.Content = rm.GetString("Login");
        }
    }
}
